<?php
namespace app\api\controller;
use app\api\model\Wxapp as WxappModel;
use app\common\library\wechat\WxPay;

/**
 * 扫码支付
 * Class Scan
 * @package app\api\controller
 */
class Scan extends \think\Controller
{

   //扫码接口
   public function index(){

       //拿到商户号id
       $wxappId=$this->request->request('wxapp_id');
       $this->payWechat($wxappId,0.1);

   }
   //发起支付
   private function payWechat($wxappId,$payPrice){
       // 统一下单API
       $orderNo=date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
       $wxConfig = WxappModel::getWxappCache($wxappId);
       $WxPay = new WxPay($wxConfig);
       $WxPay->unifiedordernative($orderNo,$payPrice, '扫码支付');
       $WxPay->orderquery($orderNo);


   }

}